package day23;

public class Demo02 {
	public static void main(String[] args) {
		// 创建线程实例
		MyThread mt = new MyThread("mt01");
		// 通过线程实例调用start()方法启动线程
		mt.start();
		//		mt.start();
		// java.lang.IllegalThreadStateException

		MyThread mt2 = new MyThread("mt02");
		//		mt2.start();

		// -----

		MyThread2 my = new MyThread2("my01");
		new Thread(my).start();
		new Thread(my).start();
		
	}
}

// --------------------------------------------

class MyThread extends Thread {

	private String myName;

	public MyThread(String myName) {
		this.myName = myName;
	}

	@Override
	public void run() {
		for (int i = 0; i < 100; i++) {
			System.out.println(myName + " - " + i);
		}
	}

}

// -------------------------------------------------

class MyThread2 implements Runnable {
	private String myName;

	public MyThread2(String myName) {
		this.myName = myName;
	}

	@Override
	public void run() {
		for (int i = 0; i < 100; i++) {
			System.out.println(myName + " - " + i);
		}
	}

}